<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/9/12
  Time: 16:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加公告</title>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery-3.1.1.js"></script>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery.validate.js"></script>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/noticeAdd.css">
    <link id="layuicss-layer" rel="stylesheet" href="file:///C:/Users/Administrator.ITIANKONG/Desktop/cpts_1065_vip-admin/frame/layui/css/modules/layer/default/layer.css?v=3.0.3" media="all"><link id="layuicss-laydate" rel="stylesheet" href="file:///C:/Users/Administrator.ITIANKONG/Desktop/cpts_1065_vip-admin/frame/layui/css/modules/laydate/default/laydate.css?v=5.0.2" media="all">
    <style>
        .showmessages{
            width: 460px;
            margin-top: 80px;
        }
    </style>
</head>
<body class="body">
<div class="pageall">
        <div class="titleall">
            <div class="titleph">
                <img src="${pageContext.request.contextPath}/static/images/gonggao.png" style="width:100%;height:100%;"/>
            </div>
            <div class="titleword">公告管理 >>> 公告添加</div>
        </div>

        <div class="contentall"></div>
    <div class="showmessages">
        <form method="post" class="layui-form" id="f">
            <div class="layui-form-item">
                <label class="layui-form-label">公告内容</label>
                <div class="layui-input-block">
                    <textarea  name="notice_content" style=" height: 200px;width: 600px;border: 1px solid darkgreen;" id="notice_content" placeholder="请输入公告内容"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">发布人姓名</label>
                <div class="layui-input-block">
                    <input type="button" name="notice_admin_name" value="${sessionScope.admin.admin_name}" style="color:#000;border:0px solid white;background-color:rgba(20,120,200,0.2);font-size:15px;" id="notice_admin_id" lay-verify="required" placeholder="请输入发布人姓名" class="layui-input">
                </div>
            </div>
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>
  </div>
</div>
<div class="shelter1">
    <div class="succ">
        <div class="tishiph1"><img src="${pageContext.request.contextPath}/static/images/cg.png" style="width:100%;height:100%;"/></div>
        <div class="confirmword1">公告添加成功！</div>
        <div class="close1"><img src="${pageContext.request.contextPath}/static/images/close.png" style="width:100%;height:100%;"/></div>
        <input type="button" class="cf1" value="确定"/>
    </div>
</div>
</body>
<script>

    $(".close1").click(function(){
        $(".shelter1").css("display","none");
        window.location.href="${pageContext.request.contextPath}/noticeAdd";
    });
    $.validator.addMethod("checkcode",function(value,element){
        var pattern = new RegExp("[<>/]");
        var specialStr = "";
        for(var i=0;i<value.length;i++){
            specialStr += value.substr(i, 1).replace(pattern, '');
        }
        if( specialStr == value){
            return true;
        }
        return false;
    },"禁止输入特殊字符");
    $("#f").validate({
        rules:{
            notice_content:{
                required:true,
                rangelength:[1,350],
                checkcode:true
            }
        },
        messages:{
            notice_content:{
                required:"*公告内容必须填写！",
                rangelength:"公告内容长度为1至350位！",
                checkcode: "请检查是否有无效字符<>/"
            }
        },
        submitHandler: function(form) {
            var param = $("#f").serialize();
            $.ajax({
                type:'POST',
                url:"${pageContext.request.contextPath}/insertnotice",
                data:param,
                dataType:"json",
                success:function(data){
                    if(data==true){
                        $.ajax({
                            type:'POST',
                            url:"${pageContext.request.contextPath}/flushnotice.do",
                            data:"",
                            dataType:"json",
                            success:function(data){
                            }
                        });
                       $(".shelter1").css("display","block");
                    }
                }
            });
        }
    });
    $(".cf1").click(function(){
        window.location.href="${pageContext.request.contextPath}/noticeAdd";
    });
</script>
</html>
